package com.qumall.boot.common;

import com.qumall.boot.entity.User;
import com.qumall.boot.service.UserService;
import com.qumall.boot.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Order(1)
public class RedisRunner implements ApplicationRunner {
    @Autowired
    UserService userService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 初始化redis连接
        Object pong = RedisUtils.ping();
        log.info("Redis 连接测试 ping --- {}", pong);
        User user = userService.getById(1);
        log.info("Mysql 连接测试 ping --- {}", user);
    }
}
